<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <link href="/res/third/bootstrap3/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script src="/res/common/js/jquery.1.9.1.min.js" type="text/javascript"></script>
    <script src="/res/third/artDialog/jquery.artDialog.js" type="text/javascript"></script>
    <script src="/res/third/validate/jquery.validate.js" type="text/javascript"></script>
    <script src="/res/third/easyUI/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/res/third/easyUI/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/res/third/My97DatePicker/WdatePicker.js"></script>
    <script src="/res/third/laytpl/template.js"></script>
    <style>
        .panel-content{overflow: scroll;}
    </style>
    <script type="text/javascript">
        function deleteRow(id) {
            art.dialog.confirm( "确认删除这个会议？", function() {
                $.post('/meeting/delete.do', { id: id },
                    function (data, textStatus, jqXHR) {
                        art.dialog.tips("删除成功！");
                        refresh();
                    });
            });
        }
        
        function changeState(id) {
            $.post('/meeting/change.do', { id: id }, function (data, textStatus, jqXHR) {
                    art.dialog.tips("设置成功！");
                    refresh();
            });
        }

        function edit(id, meetingName, address, meettime, signtime) {
            var html = template("add_dialog_template", {id: id, meetingName: meetingName, address:address, meettime: meettime, signtime: signtime});
            art.dialog({
                title: "编辑会议",
                lock:true,
                content: html,
                okVal: "提交",
                ok: submitForm
            });
        }
        
        function submitForm() {
            // 参数检测
            var meetingName = $("#add_form").find("input[name='meetingName']").val();
            if ($.trim(meetingName).length == 0) {
                alert("请输入会议名称");
                return false;
            }
            var address = $("#add_form").find("input[name='address']").val();
            if ($.trim(address).length == 0) {
                alert("请输入会议地址");
                return false;
            }
            var meettime = $("#add_form").find("input[name='meettime']").val();
            if ($.trim(meettime).length == 0) {
                alert("请输入会议时间");
                return false;
            }
            var signtime = $("#add_form").find("input[name='signtime']").val();
            if ($.trim(signtime).length == 0) {
                alert("请输入会议签到时间");
                return false;
            }
            var data=$("#add_form").serialize();
            $.post('/meeting/add.do', data, function (data, textStatus, jqXHR) {
                data = JSON.parse(data);
                if (data.success) {
                    art.dialog.tips("操作成功！");
                    refresh();
                } else {
                    art.dialog.tips(data.message);
                }
            });
        }
        $(function () {
            $(".add_row").click(function() {
                art.dialog({
                    title: "增加会议",
                    lock:true,
                    content: template("add_dialog_template", {}),
                    okVal: "提交",
                    ok: submitForm
                });
            });
        });
    </script>
</head>
<script type="text/html" id ="add_dialog_template">
    <form id="add_form" method="post" class="form-horizontal" role="form">
        <input type="hidden" name="id" value="{{id}}">
        <div class="form-group">
            <label  class="col-sm-4 control-label">会议名称</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" placeholder="请输入会议名称" min="1" value="{{meetingName}}" maxlength="100" required="required" name="meetingName">
            </div>
        </div>
        <div class="form-group">
            <label  class="col-sm-4 control-label">会议地点</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" placeholder="请输入会议地点" value="{{address}}" min="1" maxlength="100" required="required" name="address">
            </div>
        </div>
        <div class="form-group">
            <label  class="col-sm-4 control-label">参会时间</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" readonly="readonly" value="{{meettime}}" placeholder="请输入参会时间" min="1" maxlength="100" required="required" name="meettime">
            </div>
        </div>
        <div class="form-group">
            <label  class="col-sm-4 control-label">签到时间</label>
            <div class="col-sm-8">
                <input type="text" class="form-control" readonly="readonly" value="{{signtime}}" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" placeholder="请输入签到时间" min="1" maxlength="100" required="required" name="signtime">
            </div>
        </div>
    </form>
</script>
<body>
<div class="panel panel-info panel-content">
    <div class="panel-heading">
        <button class="btn btn-info add_row">
            <span class="glyphicon glyphicon-plus"></span>
            &nbsp;增加会议
        </button>
    </div>
    <table class="table table-hover table-bordered table-striped table-condensed">
        <tr>
            <th>#</th>
            <th>会议名称</th>
            <th>会议地点</th>
            <th>会议时间</th>
            <th>签到时间</th>
            <th>当前会议</th>
            <th>操作</th>
        </tr>
        [#list pagination.list as item ]
        <tr>
            <td align="center">${pagination.pageSize * (pagination.pageNo-1)+item_index+1}</td>
            <td align="center">${item.meetingName!}</td>
            <td align="center">${item.address!}</td>
            <td align="center">[#if item.meettime??]${item.meettime?string("yyyy-MM-dd HH:mm:ss")}[/#if]</td>
            <td align="center">[#if item.signtime??]${item.signtime?string("yyyy-MM-dd HH:mm:ss")!}[/#if]</td>
            <td align="center">[#if (item.state!0) == 1]是[#else]否[/#if]</td>
            <td align="center">
                [#if (item.state!0) == 0]
                <button type="button"  onclick="changeState('${item.id}')"  class="btn btn-default btn-xs btn-primary">设为当前会议</button>
                [/#if]
                <button type="button"  onclick="edit('${item.id!}', '${item.meetingName!}', '${item.address!}', '[#if item.meettime??]${item.meettime?string("yyyy-MM-dd")}[/#if]', '[#if item.signtime??]${item.signtime?string("yyyy-MM-dd HH:mm:ss")!}[/#if]')"  class="btn btn-default btn-xs btn-primary">编辑</button>
                <button type="button"  onclick="deleteRow('${item.id}')"  class="btn btn-default btn-xs btn-danger">删除</button>
            </td>
        </tr>
        [/#list]
    </table>
    <div class="panel-footer">[@fenye p = pagination form = 'infoForm' /]</div>
</div>
</body>

</html>
